package com.android.jay.lib_audio.api;

import android.content.Context;

import com.android.jay.lib_network.okhttp.CommonOkhttpClient;
import com.android.jay.lib_network.okhttp.request.CommonRequest;
import com.android.jay.lib_network.okhttp.request.RequestParams;
import com.android.jay.lib_network.okhttp.response.listener.DisposeDataHandler;
import com.android.jay.lib_network.okhttp.response.listener.DisposeDataListener;
import com.android.jay.lib_network.okhttp.response.listener.DisposeDownloadListener;


/**
 * Created by wzp on 2020/1/6 0006.
 * <p>
 * 描述  ： 请求中心
 */
public class RequestCenter {

    static class HttpConstants {
        //        private static final String ROOT_URL = "http://imooc.com/api";
        private static final String ROOT_URL = "http://39.97.122.129";

        /**
         * 首页请求接口
         */
        private static String HOME_RECOMMAND = ROOT_URL + "/module_voice/home_recommand";

        private static String HOME_RECOMMAND_MORE = ROOT_URL + "/module_voice/home_recommand_more";

        private static String HOME_FRIEND = ROOT_URL + "/module_voice/home_friend";

        /**
         * 登陆接口
         */
        public static String LOGIN = ROOT_URL + "/module_voice/login_phone";
    }

    //根据参数发送所有post请求
    public static void getRequest(String url, RequestParams params, DisposeDataListener listener,
                                  Class<?> clazz) {
        CommonOkhttpClient.get(CommonRequest.
                createGetRequest(url, params), new DisposeDataHandler(listener, clazz));
    }

    public static void getDownLoadRequest(String url, DisposeDownloadListener listener) {
        CommonOkhttpClient.downloadFile(CommonRequest.createPostRequest(url, null),
                new DisposeDataHandler(listener,"/storage/emulated/0/Android/data/"));

    }


//    public static void requestRecommandData(DisposeDataListener listener) {
//        RequestCenter.getRequest(HttpConstants.HOME_RECOMMAND, null, listener,
//                BaseRecommandModel.class);
//    }
//
//    public static void requestRecommandMore(DisposeDataListener listener) {
//        RequestCenter.getRequest(HttpConstants.HOME_RECOMMAND_MORE, null, listener,
//                BaseRecommandMoreModel.class);
//    }
//
//    public static void requestFriendData(DisposeDataListener listener) {
//        RequestCenter.getRequest(HttpConstants.HOME_FRIEND, null, listener, BaseFriendModel.class);
//    }




//    /**https测试**/
//
//    public static void testHttps(DisposeDataListener listener){
//
//        RequestParams params = new RequestParams();
//        RequestCenter.getRequest("https://www.baidu.com",null,listener,null);
//    }
}
